package com.zima.mall.controller;


import com.zima.mall.entity.MallGoods;
import com.zima.mall.service.ProductService;
import com.zima.mall.vo.TableVo;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/product")
public class ProductsController {

    @Resource
    private ProductService productService;

    @RequestMapping("/findAllGoods/{page}/{size}")
    public TableVo<MallGoods> findAllGoods(@PathVariable("page") Integer page,@PathVariable("size") Integer size){
        return productService.findAllGoods(page,size);
    }

    @RequestMapping("/deleteProduct/{id}")
    public int deleteProduct(@PathVariable Integer id){
        return productService.deleteProduct(id);
    }

    @RequestMapping("/addProduct")
    public int addProduct(@RequestBody MallGoods mallGoods){
        return productService.addProduct(mallGoods);
    }

    @RequestMapping("/findAllCategories")
    public TableVo findAllCategories(){
        return productService.findAllCategories();
    }

    @RequestMapping("/findAllHot")
    public TableVo findAllHot(){
        return productService.findAllHot();
    }

    @RequestMapping("/editProduct")
    public Integer editProduct(MallGoods mallGoods){
        return productService.editProduct(mallGoods);
    }

}
